package com.dishdex.menuhub.app.util;

import com.dishdex.menuhub.app.domain.category.CategorySubsequentLevelVO;
import com.dishdex.menuhub.app.domain.category.CategoryLevelTwoVO;
import com.dishdex.menuhub.app.domain.category.CategoryLevelOneVO;
import com.dishdex.menuhub.module.module.category.entity.Category;

import java.util.ArrayList;

/**
 * ClassName:
 * Package: com.dishdex.menuhub.app.util
 * Description:
 *
 * @Author:
 * @Create 2025/8/29 17:52
 * @Version 1.0
 */
public final class CategoryConverter {

    private CategoryConverter() {
    }

    public static CategoryLevelOneVO toCategoryLevelOneVO(Category x) {
        return new CategoryLevelOneVO()
                .setId(x.getId())
                .setCategoryImage(x.getCategoryImage() == null ? "" : x.getCategoryImage())
                .setCategoryName(x.getCategoryName() == null ? "" : x.getCategoryName())
                .setChildren(new ArrayList<>());

    }

    public static CategoryLevelTwoVO toCategoryLevelTwoVO(Category x) {
        return new CategoryLevelTwoVO()
                .setId(x.getId())
                .setCategoryImage(x.getCategoryImage() == null ? "" : x.getCategoryImage())
                .setCategoryName(x.getCategoryName() == null ? "" : x.getCategoryName());
    }

    public static CategorySubsequentLevelVO toCategoryLevelThreeVO(Category x) {
        return new CategorySubsequentLevelVO()
                .setId(x.getId())
                .setCategoryImage(x.getCategoryImage() == null ? "" : x.getCategoryImage())
                .setCategoryName(x.getCategoryName() == null ? "" : x.getCategoryName())
                .setParentId(x.getParentId());
    }
}
